/**
 * 处理响应式数据并提供自定义函数给watch
 * @param {*} vm 
 * @param {*} __get__ 
 * @param {*} __set__ 
 */
export function reactive(vm, __get__, __set__) {
  const _data = vm.$data;

  for (let key in _data) {
    Object.defineProperty(vm, key, {
      get() {
        __get__(key, _data[key]);
        return _data[key];
      },
      set(newValue) {
        const oldValue = _data[key];
        _data[key] = newValue;
        __set__(key, newValue, oldValue);
      }
    })
  }
}